//
//  UIImageView+ImageViewSize.m
//  RM_IM
//
//  Created by zhangzhenyun on 2018/7/19.
//  Copyright © 2018年 user1. All rights reserved.
//

#import "UIImageView+ImageViewSize.h"

@implementation UIImageView (ImageViewSize)
- (void)getImageSizeWithUrlStr:(NSString *)urlStr
                     completed:(GetSizeCompletedBlock)completed {
    
    NSURL *url = [NSURL URLWithString:urlStr];
    [self sd_setImageWithURL:url placeholderImage:nil options:SDWebImageRetryFailed|SDWebImageLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
    } completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        CGSize size = image.size;
        CGFloat scale = size.height / size.width;
        if (error) {
            return;
        }
        if (completed) {
            completed(error, scale, size);
        }
    }];
}
@end
